package com.cx.base.day09_utilclass;

import com.carrotsearch.sizeof.RamUsageEstimator;
import com.cx.base.day10_wrapperClass.Util_04_BigInteger;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: robert.song
 * @Date: Created in 2022/5/8
 */
@Slf4j
public class 判断对象占用内存 {
    public static void main(String[] args) {
        String str1 = new StringBuilder("计算机").append("软件").toString();
        String str2 = str1.intern();
        String str3 = "计算机软件";
        System.out.println(str2 == str1);
        System.out.println(str2 == str3);
        Integer integer = new Integer(10);
        log.info("integer数据大小：{}", RamUsageEstimator.sizeOf(integer) + "B");
        Test t = test(new 判断对象占用内存.Test());

    }

    public static <T> T test(T e) {
        ((Test) e).hah();
        return e;
    }

    static class Test {
        private void hah() {
            log.debug("Test.hah");
        }
    }
}
